package com.huijiet.controller;

import com.huijiet.base.common.CommonResult;
import com.huijiet.base.common.Ref;
import com.huijiet.param.MemberParam;
import com.huijiet.service.IMemberService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/api/member")
public class MemberController {

    @Resource
    private IMemberService memberService;


    /**用户登录*/
    @RequestMapping("/login")
    public CommonResult login(@Valid MemberParam.LoginParam param){
        return memberService.login(param);
    }

    /**修改密码*/
    @RequestMapping("/changePass")
    public CommonResult changePass(@Valid MemberParam.ChangePassParam param){
        return memberService.changePass(param);
    }

    /**测试用户是否登录*/
    @RequestMapping("/test")
    public CommonResult test(){
        return Ref.ok();
    }

    /**后台获取用户列表*/
    @RequestMapping("/list")
    public CommonResult list(@Valid MemberParam.ListParam param){
        return memberService.list(param);
    }

    /**禁用用户*/
    @RequestMapping("/disable")
    public CommonResult disable(@Valid MemberParam.DisableParam param){
        return memberService.disable(param);
    }

    /**启用用户*/
    @RequestMapping("/usable")
    public CommonResult usable(@Valid MemberParam.UsableParam param){
        return memberService.usable(param);
    }

    /**重置密码*/
    @RequestMapping("/resetPass")
    public CommonResult resetPass(@Valid MemberParam.ResetPassParam param){
        return memberService.resetPass(param);
    }

    /**新增用户*/
    @RequestMapping("/add")
    public CommonResult add(@Valid MemberParam.AddParam param){
        return memberService.add(param);
    }

    /**修改用户*/
    @RequestMapping("/modify")
    public CommonResult modify(@Valid MemberParam.ModifyParam param){
        return memberService.modify(param);
    }

    /**删除用户*/
    @RequestMapping("/delete")
    public CommonResult delete(@Valid MemberParam.DeleteParam param){
        return memberService.delete(param);
    }
}
